﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Solidi
{
	/// <summary>
	/// Represents a composer for composing and destorying objects.
	/// </summary>
	public interface IDependencyComposer
	{
		/// <summary>
		/// Composes a type using the most appropriate constructor using the supplied dependency container
		/// to resolve any constructor arguments not matched by the supplied parameters.
		/// </summary>
		/// <param name="graphId">The ID of the object graph being created.</param>
		/// <param name="container">The dependency container for the composition of the object graph being created.</param>
		/// <param name="type">The type of component to compose.</param>
		/// <param name="parameters">The parameters supplied to match against the constructor.</param>
		/// <param name="instance">The composed instance.</param>
		/// <returns>true if the type could be composed, false otherwise.</returns>
		bool TryCompose(object graphId, IDependencyContainer container, Type type, IEnumerable<IDependencyParameter> parameters, out object instance);

		/// <summary>
		/// Composes a type using the most appropriate constructor using the supplied dependency container
		/// to resolve any constructor arguments not matched by the supplied parameters.
		/// </summary>
		/// <param name="container">The dependency container for the composition of the object graph being created.</param>
		/// <param name="type">The type of component to compose.</param>
		/// <param name="parameters">The parameters supplied to match against the constructor.</param>
		/// <param name="instance">The composed instance.</param>
		/// <returns>true if the type could be composed, false otherwise.</returns>
		bool TryCompose(IDependencyContainer container, Type type, IEnumerable<IDependencyParameter> parameters, out object instance);

		/// <summary>
		/// Destorys an instance of a dependency.
		/// </summary>
		/// <param name="instance">The instance to destroy.</param>
		/// <returns>true if the instance was destroyed, false otherwise.</returns>
		bool TryDestroy(object instance);
	}
}
